<?php
/**
 * Date: 6/12/12
 * Time: 2:32 PM
 */
require_once '../bootstrap.php';

// Must login
if (empty($_SESSION['admin_id'])) {
	header('Location: login.php');
}
$self = $_SERVER['PHP_SELF'];
$__page = 'league';
// Get important fields
if( isset($_GET['del'])){
	$id = (int)$_GET['del'];
	$my_db->query("DELETE FROM leagues WHERE id = $id");
	$mess = getADMSuccess("League record/stats has been deleted.");
}
$leagues = $my_db->select_assoc('SELECT id, orgName, gender, zipcode, sport, isApproved FROM leagues');
$sports = $my_db->select_pairs('SELECT * FROM sports');

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
	"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<title><?php echo $title; ?></title>

	<style type="text/css" media="all">
		@import url("css/style.css");
		@import url("css/jquery.wysiwyg.css");
		@import url("css/facebox.css");
		@import url("css/visualize.css");
		@import url("css/date_input.css");
	</style>
	<link href="css/bootstrap.css" type="text/css" rel="stylesheet">
	<script type="text/javascript" src="js/jquery.min.js"></script>
	<script type="text/javascript" src="js/bootstrap.js"></script>
	<script type="text/javascript" src="js/jquery.dataTables.js"></script>
	<script type="text/javascript">
		$(document).ready(function () {
			$('table#dataTable').dataTable();
		});
	</script>
	<style type="text/css">
		.dataTables_filter {
			display: inline-block;
			margin-bottom: 0;
			vertical-align: middle;
			padding: 10px 10px 10px 100px;
		}

		.dataTables_length {
			display: inline-block;
			margin-bottom: 0;
			vertical-align: middle;
			padding: 10px 10px 10px 10px;
		}

		.dataTables_length select, .dataTables_length label, .dataTables_filter label, .dataTables_filter input {
			display: inline-block;
			margin-bottom: 0;
			vertical-align: middle;
		}

		.dataTables_info {
			background-color: #3a87ad;
			color: #f8f8ff;
		}
	</style>
</head>
<body>
<div id="hld">

	<div class="wrapper">        <!-- wrapper begins -->

		<?php include("__menu.php");?>
		<!-- #header ends -->
		<!-- .block ends -->
		<div class="block">
			<div class="block_head">
				<div class="bheadl"></div>
				<div class="bheadr"></div>
				<h2>Ads List</h2>
			</div>
			<!-- .block_head ends -->
			<div class="block_content">
				<?php echo isset($mess)?$mess:''; ?>
	<table class="table table-striped table-bordered table-condensed" id="dataTable">
		<thead>
		<tr>
			<th>Id</th>
			<th>OrgName</th>
			<th>Gender</th>
			<th>Zipcode</th>
			<th>Sport</th>
			<th>Command</th>
		</tr>
		</thead>
		<tbody>
		<?php
		foreach ($leagues as $league) {
			$approve = ($league['isApproved'])?'Unapprove':'Approve';
			?>
			<tr>
				<td><?= htmlspecialchars($league['id'], ENT_QUOTES, 'UTF-8')  ?></td>
				<td><?= htmlspecialchars($league['orgName'], ENT_QUOTES, 'UTF-8') ?></td>
				<td><?= htmlspecialchars($league['gender'], ENT_QUOTES, 'UTF-8') ?></td>
				<td><?= htmlspecialchars($league['zipcode'], ENT_QUOTES, 'UTF-8') ?></td>
				<td><?= htmlspecialchars($sports[$league['sport']], ENT_QUOTES, 'UTF-8')  ?></td>
				<td>
					<a href="add_edit_league.php?id=<?= $league['id'] ?>" title="Edit"><img src="images/edit_icon.gif" width="16" height="16" alt="Edit" /></a> &nbsp;&nbsp;
					<a href="<?= $self?>?del=<?=$league['id'] ?>" onclick="return confirm('Do you want delete this?')" title="Delete"><img src="images/del_icon.gif" width="16" height="16" alt="Delete"/></a> &nbsp;
					<a href="approve_unprove.php?id=<?=$league['id'];?>&type=league" onclick="return confirm('Do you want <?= $approve?> this?')" title="<?= $approve?>"><img src="images/<?=$approve?>.jpg" width="16" height="16" alt="<?=$approve?>"/></a>
				</td>
			</tr>
			<?php
		}
		?>
		</tbody>
	</table>
			</div>
		</div>
	</div>
	<?php include("__footer.php"); ?>
</div>
</body>
</html>
